<template>
	<view class="mainpadding2">
		<view class="" style="padding-bottom: 140rpx;">
			<view class="ffffff radius mainpadding margin_top dingwei" v-for="item in list.data" :key="item.id">
				<view class="qptbn flexcenter" v-if="item.status==1">启用</view>
				<view class="jtbtn flexcenter" v-if="item.status==2">禁用</view>
				<view class="xiahuaxian">
					<view class="sanshier fonweight zhonghei">{{item.name}}</view>
					<view class="ershiba xiaohui fonweight margin_top2">手机号：{{item.mobile}}</view>
					<view class="ershiba xiaohui fonweight margin_top2">员工权限：{{returnqx(item.rolelist)}}</view>
				</view>
				<view class="flexright margin_top">
					<view class="xgbtn flexcenter margin_right3" @click="tzxzdybj(item.id)">
						<image style="width: 16rpx;height: 20rpx;" src="../static/images/system/xh.png" mode=""></image>
						<view class="margin_left1">修改信息</view>
					</view>
					<view class="xgbtn flexcenter" @click="shanchu(item.id)">
						<u-icon name="trash" color="#FF9341"></u-icon>
						<view class="" style="margin-left: 5rpx;">删除此人</view>
					</view>
				</view>
			</view>
		</view>
		<view class="gudingdb mainpadding ffffff" @click="tzxzdy">
			<view class="bigbtn">新增店员</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				listid: "",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.listid = options.id
			
		},
		onShow() {
			this.init()
		},
		methods: {
			shanchu(id) {
				httpRequest.modal('提示', '是否确认删除', true, (resp) => {
					if (resp) {
						httpRequest.request('/api/shopcl/delShopUser', 'GET', {
							shop_id:this.listid,
							id: id,
						}).then(res => {
							httpRequest.toast(res.msg)
							this.init()
						})
					}
				})
			},
			returnqx(val) {
				let arr = ['扫码核销', '输码核销', '商品管理', '保证金', '编辑信息', '店员管理', '订单管理', '收益']
				if (val == 0) {
					return arr.join("/")
				} else {
					let qxtext = []
					let qxarr = val.split(",")
					qxarr.forEach(item => {
						qxtext.push(arr[Number(item) - 1])
					})
					return qxtext.join("/")
				}

			},
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/shopcl/shopUserIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
					shop_id: this.listid,
				}).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 跳转新增店员
			tzxzdy() {
				uni.navigateTo({
					url: '/pages_wode/xinzengdy?shop_id=' + this.listid
				})
			},
			tzxzdybj(id) {
				uni.navigateTo({
					url: '/pages_wode/xinzengdy?shop_id=' + this.listid + "&id=" + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.jtbtn {
		width: 138rpx;
		height: 58rpx;
		background: #fdedea;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #EB4625;
		position: absolute;
		top: 0;
		right: 0;
		border-radius: 0rpx 16rpx 0rpx 16rpx;
	}

	.qptbn {
		width: 138rpx;
		height: 58rpx;
		background: #fff5ec;
		font-size: 24rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
		position: absolute;
		top: 0;
		right: 0;
		border-radius: 0rpx 16rpx 0rpx 16rpx;
	}

	.xgbtn {
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #FF9341;
		width: 189rpx;
		height: 70rpx;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		opacity: 1;
		border: 1rpx solid #FF9341;
	}
</style>